import { Controller, Post, Get, Body } from '@nestjs/common'
import { Prisma } from '@prisma/client'
import { CategoryService } from './category.service'

@Controller('category')
export class CategoryController {
  constructor(private readonly categoryService: CategoryService) {}

  @Post()
  async createCategory(@Body() data: Prisma.CategoryCreateInput) {
    const category = await this.categoryService.createCategory(data)
    return {
      statusCode: 200,
      message: 'OK',
      data: {
        category
      }
    }
  }

  @Get()
  async getCategorys() {
    const categorys = await this.categoryService.getCategorys()
    return {
      statusCode: 200,
      message: 'OK',
      data: {
        categorys
      }
    }
  }
}
